#include <iostream>
using namespace std;
#include <string> 
#include <vector>

int process(string& str , int index) 
{
  if (index == static_cast<int> (str.length())) 
  {
    return 1;
  }

  if (str[index] == '0')
  {
    return 0;
  }

  // need cur 
  // need cur + 1 ? 
  int p1 = process(str , index + 1);
  int p2 = 0;
  if (index + 1 < static_cast<int>(str.length()) &&  (str[index] - '0') * 10 + (str[index+1] - '0')  < 27 )
  {
    p2 = process(str , index + 2); 
  }

  return p1 + p2;
}

int process1(string& str , vector<int>& dp )
{
  dp[static_cast<int>(str.size())] = 1;

  for (int i = static_cast<int>(str.size()) - 1 ; i >= 0 ; i--)
  {

    if (str[i] == '0')
    {
      continue;
    }


    int p1 = dp[i+1] ;
    int p2 = 0;

    if (i + 1 < static_cast<int>(str.length()) &&  (str[i] - '0') * 10 + (str[i+1] - '0')  < 27 )
    {
       p2 = dp[i+2];     
    }

    dp[i] = p1 + p2;
  }

  return dp[0];
}


int main()
{
  string str = "11111";

  vector<int> dp(str.size() + 1, 0);
  int ret1 = process(str , 0);
  int ret = process1(str , dp);
  cout << ret << endl;
  cout << ret1 << endl;
  return 0;
}
